const { Sequelize } = require('sequelize')
 const { MYSQL_DB, MYSQL_USER, MYSQL_PWD, MYSQL_HOST, MYSQL_PORT } = require('../config/config.default.js');

    // console.log('111111'+MYSQL_HOST+ MYSQL_PORT+MYSQL_USER,+MYSQL_PWD+MYSQL_DB);
const sequelize = new Sequelize(MYSQL_DB, MYSQL_USER, MYSQL_PWD, {
    host: Number(MYSQL_PORT),
    dialect: 'mysql'
});
// const sequelize = new Sequelize('training', 'root', '123456', {
//     host: 3306,
//     dialect: 'mysql'
// });
module.exports = sequelize

sequelize
    .authenticate()
    .then(() => {
        console.log('数据库连接成功')
    })
    .catch((err) => {
        console.log('数据库连接失败',err)
    })